#ifndef ZG_DAEMON_H
#define ZG_DAEMON_H


#include "cstring"
#include "string"
#include "sstream"
#include "unistd.h"
#include "wait.h"
#include <fcntl.h>
#include "DateTime.h"
#include <sys/stat.h>
#include "cstdarg"
#include "cstdlib"
using std::string;

#define DAEMON_INIT(x,y) zg_util::Daemon::InitDaemon(x,y);
namespace zg_util{
    class Daemon{
    public:
        static int InitDaemon(int child_pro_count,int closefd,char* pwd=NULL);
    private:
        static void set_child_sig();
        static void set_father_sig();
        static void Log(const char* log_str,...);
        static void signal_handler(int sig);
        static volatile sig_atomic_t app_shutdown;
        static volatile sig_atomic_t child;
    };
}

#endif
